Index
Table of Content
Install#
install
pip install fastapi uvicorn
Define the API Endpoints#
from fastapi import FastAPI
app = FastAPI()
@app.get("/hello")
def hello(name: str = ""):
return {"message": f"Hello {name}"}
import uvicorn
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
Test#
from cli
curl http://localhost:8000/hello?name=john